package demo4;
//接口
interface IRunning{
    void run();
}
interface ISwimming{
    void swim();
}
interface IFlying{
    void fly();
}
//类
class Animals{
    public String name;

    public Animals(String name) {
        this.name = name;
    }

    public void eat(){
        System.out.println("正在吃饭");
    }
}
//重写抽象方法快捷键：alt+enter
class Dog extends Animals implements IRunning,ISwimming{
    public Dog(String name) {
        super(name);
    }
    @Override
    public void run() {
        System.out.println(name+"正在跑");
    }

    @Override
    public void swim() {
        System.out.println(name+"正在游泳");
    }
    public void eat(){
        System.out.println(name+"正在吃狗粮");
    }
}
class Duck extends Animals implements IRunning,ISwimming,IFlying{

    public Duck(String name) {
        super(name);
    }
    @Override
    public void run() {
        System.out.println(name+"正在跑");
    }

    @Override
    public void swim() {
        System.out.println(name+"正在游泳");
    }

    @Override
    public void fly() {
        System.out.println(name+"正在飞");
    }
    public void eat(){
        System.out.println(name+"正在吃鸭粮");
    }
}
class Robert implements IRunning{

    @Override
    public void run() {
        System.out.println("机器人正在跑");
    }
}
public class Test {
    //跑
    public static void isRun(IRunning running){
        running.run();
    }
    //游泳
    public static void isSwim(ISwimming swimming){
        swimming.swim();
    }
    //吃
    public static void isEat(Animals animals){
        animals.eat();
    }
    public static void main(String[] args) {
        //跑：
        isRun(new Dog("小狗"));
        isRun(new Duck("小鸭子"));
        isRun(new Robert());
        System.out.println("-------------------");
        //游泳：
        isSwim(new Dog("小狗"));
        isSwim(new Duck("小鸭子"));
        System.out.println("-------------------");
        //吃
        isEat(new Dog("小狗"));
        isEat(new Duck("小鸭子"));



    }
}
